Skip to content

Approximate annotated types in wildApprox #22893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged

Conversation

mbovel
Copy link
Member

@mbovel mbovel commented Apr 1, 2025

Fixes #22874.

wildApprox approximates parameter references and type variables by wildcards. When doing so for an AnnotatedType, this can produce trees with wildcards types, causing the type assigner to fail. For example, consider Apply(fn, args) where fn has type TermParamRef. Applying wildApprox will approximate the type of fn to a wildcard, leading the type assigner for Apply to emit an error stating that <?> does not take parameters.

This issue is somehow similar to the one described in #19957 (comment), which was fixed by #21941 (and re-worked in #22839).

This PR fixes the issue by approximating annotated types in wildApprox: annotated types are approximated by their parent types if they are not refining, or by wildcards upper-bounded by their parent types if they are.

@mbovel mbovel requested a review from smarter April 1, 2025 11:29
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, maybe add a comment in the added case pointing to the test for illustration?

@mbovel
Copy link
Member Author

mbovel commented Apr 1, 2025

Thanks a lot for the quick review! Comment added!

@mbovel mbovel merged commit 72d0026 into scala:main Apr 1, 2025
29 checks passed
@mbovel mbovel deleted the mb/22874 branch April 1, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants